<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <h1 id="count">1</h1>
    <button id="btn">add</button>
  </div>

  <script>
    let obj = {
      count: 1,
    }
    let value = obj.count;

    Object.defineProperty(obj, 'count', {
      get() {
        return value;
      },
      set(newVal) {
        value = newVal;
        h1.innerHTML = value
      }
    })

    const btn = document.getElementById('btn');
    const h1 = document.getElementById('count');

    btn.addEventListener('click', () => {
      obj.count++;
    });
  </script>
</body>

</html>